export const resourcePaths = {
  avatar: `/avatar/$$.png`,
  gameTypeIcon: `/game/type/$$.png`,
};

/**
 * 获取用户头像路径
 */
export function getAvatarPath(level: number) {
  return `/avatar/${level}.png`;
}

/**
 * 获取游戏类型图标路径
 */
export function getGameTypeIconPath(type: string) {
  return `/game/type/${type}.png`;
}

/**
 * 获取资源路径
 */
export function getResourcePath(type: keyof typeof resourcePaths, value: undefined | null | string | number) {
  const v = value?.toString() ?? '';
  return v ? resourcePaths[type].replace('$$', v) : '';
}

/**
 * 连接路径
 */
export function joinPath(...paths: string[]) {
  return paths.map(path => path.trim().replace(/^\/+|\/+$/g, '')).join('/');
}
